import axios from 'axios'
import qs from 'qs'

axios.defaults.baseURL = ''

const maxios = function (url, method, data = {}) {
    return new Promise((resolve => {
        if (method == 'get' || method == "delete") {
            axios({'url': url, 'method': method, 'params': data})
                .then(res => {
                    return resolve(res.data)
                })
        } else {
            axios({'url': url, 'method': method, 'data': qs.stringify(data)})
                .then(res => {
                    return resolve(res.data)
                })
        }
    }))
}
export default maxios;
